/* User-Defined Function Objects for Function Adapters */

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <functional>
#include "fopow.h"

using namespace std;

int main()
{
	vector<int> coll = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

	// print 3 raised to the power of all elements
	transform(coll.begin(), coll.end(),
		ostream_iterator<float>(cout, " "),
		bind(fopow<float, int>(), 3, std::placeholders::_1));
	cout << endl;

	// print all elements raised to the power of 3
	transform(coll.begin(), coll.end(),
		ostream_iterator<float>(cout, " "),
		bind(fopow<float, int>(), std::placeholders::_1, 3));
	cout << endl;

	return 0;
}